{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Mainc where

import Text.Hamlet(HtmlUrl,hamlet)
import Text.Blaze.Html.Renderer.String (renderHtml)
import Data.Text(Text,append,pack)
import Control.Arrow (second)
import Network.HTTP.Types(renderQueryText)
import Data.Text.Encoding(decodeUtf8)
import Blaze.ByteString.Builder(toByteString)


data MyRoute = SomePage | MyPage

render :: MyRoute ->[(Text,Text)] -> Text
render SomePage params = "/home" `append` decodeUtf8 (toByteString $ renderQueryText True (map (second Just) params))
render MyPage params = "/home111" `append` decodeUtf8 (toByteString $ renderQueryText True (map (second Just) params)) 
    
main :: IO ()
main = putStrLn $ renderHtml $[hamlet|
<p>
    $if currentPage < 5
        You are currently on page #{currentPage}
    $else
        You are to End
    <a href=@?{(SomePage,[("page", pack $ show $ currentPage - 1)])}>Previous
    <a href=@?{(MyPage,[("page", pack $ show $ currentPage + 1)])}>Next
|] render
    where currentPage =8 :: Int
          idvalue=123::Int
